package ir.mirrajabi.searchdialog.core;

import ohos.agp.components.TextFilter;

import java.util.ArrayList;

/**
 * Created by MADNESS on 6/3/2017.
 * 过滤封装类
 */
public abstract class BaseFilter<T> extends TextFilter {
    private OnPerformFilterListener mOnPerformFilterListener;
    private ArrayList<T> mItems;
    private FilterResultListener mFilterResultListener;

    /**
     * 获取监听
     * @return OnPerformFilterListener
     */
    public OnPerformFilterListener getOnPerformFilterListener() {
        return mOnPerformFilterListener;
    }

    /**
     * 设置监听
     * @param onPerformFilterListener onPerformFilterListener
     * @return BaseFilter
     */
    public BaseFilter setOnPerformFilterListener(OnPerformFilterListener onPerformFilterListener) {
        mOnPerformFilterListener = onPerformFilterListener;
        return this;
    }

    /**
     * 过滤后
     */
    public void doAfterFiltering() {
        if (mOnPerformFilterListener != null) {
            mOnPerformFilterListener.doAfterFiltering();
        }
    }

    /**
     * 过滤前
     */
    public void doBeforeFiltering() {
        if (mOnPerformFilterListener != null) {
            mOnPerformFilterListener.doBeforeFiltering();
        }
    }

    /**
     * 获取列表集合
     * @return ArrayList
     */
    public ArrayList<T> getItems() {
        return mItems;
    }

    /**
     * 设置列表集合
     * @param items items
     * @return BaseFilter
     */
    public BaseFilter setItems(ArrayList<T> items) {
        mItems = items;
        return this;
    }

    /**
     * 获取过滤结果监听
     * @return FilterResultListener
     */
    public FilterResultListener getFilterResultListener() {
        return mFilterResultListener;
    }

    /**
     * 设置过滤结果监听
     * @param filterResultListener filterResultListener
     * @return BaseFilter
     */
    public BaseFilter setFilterResultListener(FilterResultListener filterResultListener) {
        mFilterResultListener = filterResultListener;
        return this;
    }
}
